package com.example.multiplesprite;

import android.graphics.Canvas;

public class GameThread extends Thread {
       private GameController _gameController;
       private boolean _isRunning = false;     

       public GameThread(GameController _gameController) {
             this._gameController = _gameController;
       }

       public void setRunning(boolean run) {
             _isRunning = run;
       }

       @Override
       public void run() {
          while (_isRunning) {
                  Canvas _canvas = null;
                    try {
                    	_canvas = _gameController.getHolder().lockCanvas();
                           synchronized (_gameController.getHolder()) {
                                  _gameController.onDraw(_canvas);
                           }

                    } finally {
                           if (_canvas != null) {
                                  _gameController.getHolder().unlockCanvasAndPost(_canvas);
                           }
                    }
             }
       }

}